/* Project 7 Virtual Machine
   File: token.h */
#define OPCODECOUNT 13
#define REGISTERCOUNT 8

/* An enumeration of possible Opcodes */
enum Opcode {MOV = 0, ADD = 1, SUB = 2, MUL = 3, DIV = 4, 
			 GET = 5, FGET = 6, PUT = 7, JMNZ = 8, JMZ = 9, 
			 JMP = 10, JMN = 11, GOTO = 12};

/* An enumeration of possible Registers */
enum Register {R0 = 0, R1 = 1, R2 = 2, R3 = 2, 
			   R4 = 3, R5 = 4, R6 = 5, R7 = 6};

/* An enumeration of possible Lexeme types */
enum DataType {INTEGER, FLOAT, REGISTER, OPCODE, STRING, LABEL};

/* A structure to hold data in the Registers */
struct RegisterData
{
	enum DataType t;
	union 
	{
		int i;
		float f;
		char *str;
	} v;
};

/* A union of possible values of a token */


/* A token */
struct Token
{
	union 
	{
		int i;
		float f;
		enum Register r;
		enum Opcode op;
		char *str;
		char *lbl;
	} v;
	enum DataType type;
	struct Token *next;
	int line_num;
};

/* A Linked list of tokens */
struct TokenList
{
	struct Token *head;
	struct Token *tail;
};

/* Functions to run the lexer and add tokens to the list */
void Add_Token(struct TokenList *token_list, struct Token *token);
void Free_TokenList(struct TokenList *token_list);
int Has_More_Tokens(FILE *input);
int Is_Valid_Token(struct Token *token);
struct Token *Next_Token(char *line, int line_num);
void Print_Token(struct Token *token, FILE *output);
struct Token *Read_Token(FILE *input, FILE *error);
struct TokenList New_TokenList();